package com.wn.controller;

import com.wn.entity.Goods;
import com.wn.entity.GoodsDTO;
import com.wn.service.IGoodsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private IGoodsService goodsService;
    
    @ApiOperation("添加")
    @PostMapping
    public String createProject(@RequestBody GoodsDTO goodsDTO) {
        goodsService.saveGoods(goodsDTO);
        return "ok";
    }

    @ApiOperation("商品列表")
    @GetMapping(value = "/list")
    public List<Goods> queryGoods(){
        List<Goods> list = goodsService.list();
        return list;
    }

    @ApiOperation("商品明细列表")
    @GetMapping(value = "/list/detail")
    public List<GoodsDTO> queryGoodsDetail(){
        List<GoodsDTO> list = goodsService.queryGoodsDetail();
        return list;
    }
}